#ifndef TOOL_QRDECODER_H
#define TOOL_QRDECODER_H

#include "opencv2/opencv.hpp"
#include <QObject>
#include <QImage>
#include <QMutex>
#include <QDebug>
#include <QTimerEvent>

class Tool_qrdecoder : public QObject
{
    Q_OBJECT
public:
    explicit Tool_qrdecoder(QObject *parent = nullptr);
    ~Tool_qrdecoder();
    Q_INVOKABLE void dectanddecoderQRcode(QImage img);
    Q_INVOKABLE void setImage(QImage img);
    Q_INVOKABLE void  onstartDecoder();
    Q_INVOKABLE void  stopDecoder();

protected:
     void timerEvent(QTimerEvent *event) override;



signals:
    void  qrDecodersuccess(QString res);
    void  qrDecoderfailed();
    void startDecoder();
private:
    cv::Mat  QImage2cvMat(const QImage img);


    QImage m_image;
    int m_timerId=-1;

    QMutex m_mutex;
};
class Tool_qr:public QObject{
    Q_OBJECT
public:
    explicit Tool_qr();
    ~Tool_qr();
    Q_INVOKABLE void setIame(const QImage img);

private:
    Tool_qrdecoder *m_tool_qrdecoder;
};

#endif // TOOL_QRDECODER_H
